﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="ManageCars.aspx.cs" Inherits="DrivingCRM.Views.Private.CRM.ManageCar" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="banniere" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="nav" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contenu" runat="server">
    <asp:EntityDataSource ID="DS_Agencies" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
        EntitySetName="AgencySet" EntityTypeFilter="Agency">
    </asp:EntityDataSource>

    <h2>Gestion des voitures</h2>

    Agence:
    <asp:DropDownList ID="DDL_Agencies" runat="server" DataSourceID="DS_Agencies" 
        DataTextField="Name" DataValueField="IdAgency" AutoPostBack="true">
    </asp:DropDownList>

    <asp:ListView ID="LV_Cars" runat="server" DataKeyNames="IdVehicle" 
        DataSourceID="DS_Cars" GroupItemCount="1" InsertItemPosition="None" OnItemCancelling="LV_Cars_ItemCancelling"
        OnItemInserting="LV_Cars_ItemInserting" OnItemUpdating="LV_Cars_ItemUpdating">
        <AlternatingItemTemplate>
            <td runat="server" style="background-color:#FFF8DC;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Marque:</td>
                        <td><asp:Label ID="BrandLabel" runat="server" Text='<%# Eval("Brand") %>' /></td>
                    </tr>
                    <tr>
                        <td>Modèle:</td>
                        <td><asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>' /></td>
                    </tr>
                    <tr>
                        <td>Année de mise en circulation:</td>
                        <td><asp:Label ID="Created_yearLabel" runat="server" Text='<%# Eval("Created_year") %>' /></td>
                    </tr>
                    <tr>
                        <td>Immatriculation:</td>
                        <td><asp:Label ID="LicenceLabel" runat="server" Text='<%# Eval("Licence") %>' /></td>
                    </tr>
                    <tr>
                        <td>Date de la dernière révision:</td>
                        <td><asp:Label ID="LastRevisionDateLabel" runat="server" Text='<%# Eval("LastRevisionDate") %>' /></td>
                    </tr>
                    <tr>
                        <td>Nombre de places assises:</td>
                        <td><asp:Label ID="Seating_numberLabel" runat="server" Text='<%# Eval("Seating_number") %>' /></td>
                    </tr>
                    <tr>
                        <td>Agence:</td>
                        <td><asp:Label ID="AgencyLabel" runat="server" Text='<%# Eval("Agency.Name") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Supprimer" /></td>
                        <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                    </tr>
                </table>
            </td>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <td runat="server" style="background-color:#008A8C;color: #FFFFFF;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Marque:</td>
                        <td><asp:TextBox ID="BrandTextBox" runat="server" Text='<%# Bind("Brand") %>' /></td>
                    </tr>
                    <tr>
                        <td>Modèle:</td>
                        <td><asp:TextBox ID="ModelTextBox" runat="server" Text='<%# Bind("Model") %>' /></td>
                    </tr>                
                    <tr>
                        <td>Année de mise en circulation:</td>
                        <td>
                            <telerik:RadDatePicker ID="RDP_CreatedYear" runat="server" SelectedDate='<%# Bind("Created_year") %>'>
                            </telerik:RadDatePicker></td>
                        
                        
                        </td>
                    </tr>
                    <tr>
                        <td>Immatriculation:</td>
                        <td><asp:TextBox ID="LicenceTextBox" runat="server" Text='<%# Bind("Licence") %>' /></td>
                    </tr>
                    <tr>
                        <td>Date de la dernière révision:</td>
                        <td>
                            <telerik:RadDatePicker ID="RDP_LastRevisionDate" runat="server" SelectedDate='<%# Bind("Created_year") %>'>
                            </telerik:RadDatePicker></td>
                        
                        
                        <asp:TextBox ID="LastRevisionDateTextBox" runat="server" Text='<%# Bind("LastRevisionDate") %>' /></td>
                    </tr>
                    <tr>
                        <td>Nombre de places assises:</td>
                        <td><asp:TextBox ID="Seating_numberTextBox" runat="server" Text='<%# Bind("Seating_number") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Mettre à jour" /></td>
                        <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Annuler" /></td>
                    </tr>
                </table>
            </td>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table runat="server" 
                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                <tr>
                    <td>
                        <h2>Aucune voiture en base.</h2></td>
                </tr>
                <tr>
                    <td><asp:Button ID="B_AddCar" runat="server" Text="Ajouter une voiture" OnClick="B_AddCar_Click" /> </td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <EmptyItemTemplate>
<td runat="server" />
        </EmptyItemTemplate>
        <GroupTemplate>
            <tr ID="itemPlaceholderContainer" runat="server">
                <td ID="itemPlaceholder" runat="server">
                </td>
            </tr>
        </GroupTemplate>
        <InsertItemTemplate>
            <td runat="server" style="">
                <table class="Table_ItemList">
                    <tr>
                        <td>Marque:</td>
                        <td><asp:TextBox ID="BrandTextBox" runat="server" Text='<%# Bind("Brand") %>' /></td>
                    </tr>
                    <tr>
                        <td>Modèle:</td>
                        <td><asp:TextBox ID="ModelTextBox" runat="server" Text='<%# Bind("Model") %>' /></td>
                    </tr>
                    <tr>
                        <td>Année de mise en circulation:</td>
                        <td>
                            <telerik:RadDatePicker ID="RDP_CreatedYear" runat="server" SelectedDate='<%# Bind("Created_year") %>'>
                            </telerik:RadDatePicker></td>
                    </tr>
                    <tr>
                        <td>Immatriculation:</td>
                        <td><asp:TextBox ID="LicenceTextBox" runat="server" Text='<%# Bind("Licence") %>' /></td>
                    </tr>
                    <tr>
                        <td>Date de la dernière révision:</td>
                        <td>
                            <telerik:RadDatePicker ID="RDP_LastRevisionDate" runat="server" SelectedDate='<%# Bind("Created_year") %>'>
                            </telerik:RadDatePicker></td>
                       </td>
                    </tr>
                    <tr>
                        <td>Nombre de places assises:</td>
                        <td><asp:TextBox ID="Seating_numberTextBox" runat="server" Text='<%# Bind("Seating_number") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insérer" /></td>
                        <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Annuler" /></td>
                    </tr>
                </table>
            </td>
        </InsertItemTemplate>
        <ItemTemplate>
            <td runat="server" style="background-color:#DCDCDC;color: #000000;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Marque:</td>
                        <td><asp:Label ID="BrandLabel" runat="server" Text='<%# Eval("Brand") %>' /></td>
                    </tr>
                    <tr>
                        <td>Modèle:</td>
                        <td><asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>' /></td>
                    </tr>
                    <tr>
                        <td>Année de mise en circulation:</td>
                        <td><asp:Label ID="Created_yearLabel" runat="server" Text='<%# Eval("Created_year") %>' /></td>
                    </tr>
                    <tr>
                        <td>Immatriculation:</td>
                        <td><asp:Label ID="LicenceLabel" runat="server" Text='<%# Eval("Licence") %>' /></td>
                    </tr>
                    <tr>
                        <td>Date de mise en circulation:</td>
                        <td><asp:Label ID="LastRevisionDateLabel" runat="server" Text='<%# Eval("LastRevisionDate") %>' /></td>
                    </tr>
                    <tr>
                        <td>Nombre de places assises:</td>
                        <td><asp:Label ID="Seating_numberLabel" runat="server" Text='<%# Eval("Seating_number") %>' /></td>
                    </tr>
                    <tr>
                        <td>Agence:</td>
                        <td><asp:Label ID="AgencyLabel" runat="server" Text='<%# Eval("Agency.Name") %>' /></td>
                    </tr>  
                    <tr>
                        <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Supprimer" /></td>
                        <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                    </tr> 
                </table>
            </td>
        </ItemTemplate>
        <LayoutTemplate>
            <table runat="server">
                <tr runat="server">
                    <td runat="server">
                        <table ID="groupPlaceholderContainer" runat="server" border="1" 
                            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr ID="groupPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr runat="server">
                    <td runat="server" 
                        style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                        <asp:DataPager ID="DataPager1" runat="server" PageSize="12">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" PreviousPageText="Précédent" FirstPageText="Première page" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" NextPageText="Suivant" LastPageText="Dernière page" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
                <tr runat="server">
                    <td runat="server"><asp:Button ID="B_AddCar" runat="server" Text="Ajouter une voiture" OnClick="B_AddCar_Click" /> </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:EntityDataSource ID="DS_Cars" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" EntitySetName="VehicleSet" 
        EntityTypeFilter="Car" Include="Agency"
        Where="it.AgencyIdAgency == @CurrentAgency">
        <WhereParameters>
            <asp:ControlParameter ControlID="DDL_Agencies" DbType="Int32" Name="CurrentAgency" PropertyName="SelectedValue" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="footer" runat="server">
</asp:Content>
